package com.roomaja.roomaja.controller;

import com.alibaba.fastjson.JSONArray;
import com.roomaja.roomaja.entity.BackgroundPictureEntity;
import com.roomaja.roomaja.entity.WenKuEntity;
import com.roomaja.roomaja.mapper.BackgroundPictureMapper;
import com.roomaja.roomaja.mapper.WenKuEntityMapper;
import com.roomaja.roomaja.service.WenKuPageProcessor;
import com.roomaja.roomaja.tool.PageBean;
import com.roomaja.roomaja.tool.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import us.codecraft.webmagic.Spider;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * controller层
 */

@RestController
@RequestMapping("/wenku")
public class WenkuController {

    private Logger logger = Logger.getLogger(WenkuController.class);
    @Autowired
    WenKuPageProcessor wenKuPageProcessor;

    /**
     * 跳转到文档详细页
     * @return
     */
    @RequestMapping(value = "/{docId}/details",method = RequestMethod.GET)
    public ModelAndView details(@PathVariable("docId") String docId){
        ModelAndView model = new ModelAndView("details");
        WenKuEntity wenKuEntity = wenKuPageProcessor.getDetailByDocId(docId);
        if(wenKuEntity == null){
            logger.error("文档不存在");
        }

        model.getModel().put("wenku",wenKuEntity);
        return model;
    }

}
